package com.spzx.product.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.security.annotation.InnerAuth;
import com.spzx.product.domain.ProductDetails;
import com.spzx.product.service.ProductDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ProductDetailsController
 * @Author 波
 * @Date 2024/8/5 20:14
 */
@RestController
@RequestMapping("/productDetails")
public class ProductDetailsController extends BaseController {
    @Autowired
    private ProductDetailsService productDetailsService;

    @InnerAuth
    @GetMapping("/{pid}")
    public R<ProductDetails> details(@PathVariable("pid") Long pid) {
        LambdaQueryWrapper<ProductDetails> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductDetails::getProductId,pid);
        ProductDetails productDetails = productDetailsService.getOne(queryWrapper);
        return R.ok(productDetails);
    }

}
